package com.sicheng.lc.lc笔试._360篇;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/9/3 23:58
 */
public class 删数 {
    /**
     * nums数组 输入x 原地修改nums，删掉nums中所有x
     * 输出新数组的长度
     */

    public int delete(int[] a, int x) {

        int l = a.length;
        for (int i = 0; i < a.length; i++) {
            if (a[i] == x) {
                l = i;
                break;
            }
        }
        for (int i = l + 1; i < a.length; i++) {
            if (a[i] == x)
                continue;
            a[l++] = a[i];
        }

        return l;

    }

    public static void main(String[] args) {


    }
}
